home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / lib / mathlib / libconv / TRY / ornl_diir2d.f < prev    next >
Encoding:
Text File  |  1994-08-02  |  5.2 KB  |  168 lines

  1.       subroutine ornl_diir2d(    f,incf,ldf,ifx0,n_fx,ify0,n_fy,
  2.      $                g,incg,ldg,igx0,n_gx,igy0,n_gy,
  3.      $                h,inch,ldh,ihx0,n_hx,ihy0,n_hy)
  4.       double precision f(ldf,*)
  5.       double precision g(ldg,*)
  6.       double precision h(ldh,*)
  7.       integer incf, ldf, ifx0, n_fx, ify0, n_fy
  8.       integer incg, ldg, igx0, n_gx, igy0, n_gy
  9.       integer inch, ldh, ihx0, n_hx, ihy0, n_hy
  10. c-----------------------------------------------------------------------------
  11. c
  12. c   diir2d  performs a 2D convolution in the time domain :
  13. c    h(i,j) = beta * h(i,j) + alpha * Sum.Sum[ f(k,l) * g(i-k,j-l) ]
  14. c
  15. c-----------------------------------------------------------------------------
  16. c
  17. c   PARAMETERS:
  18. c
  19. c    f:    Vector containing sequence "f"
  20. c    incf:    Increment between two successive lines   of "f"
  21. c    ldf:    Increment between two successive columns of "f"
  22. c    ifx0:    Index of the first element of each column of "f"
  23. c    n_fx:    Number of elements (lines) of each column of "f"
  24. c    ify0:    Index of the first column of "f"
  25. c    n_fy:    Index of the  last column of "f"
  26. c    
  27. c    g:    Vector containing sequence "g"
  28. c    incg:    Increment between two successive lines   of "g"
  29. c    ldg:    Increment between two successive columns of "g"
  30. c    igx0:    Index of the first element of each column of "g"
  31. c    n_gx:    Number of elements (lines) of each column of "g"
  32. c    igy0:    Index of the first column of "g"
  33. c    n_gy:    Index of the  last column of "g"
  34. c    
  35. c    h:    Vector containing sequence "h"
  36. c    inch:    Increment between two successive lines   of "h"
  37. c    ldh:    Increment between two successive columns of "h"
  38. c    ihx0:    Index of the first element of each column of "h"
  39. c    n_hx:    Number of elements (lines) of each column of "h"
  40. c    ihy0:    Index of the first column of "h"
  41. c    n_hy:    Index of the  last column of "h"
  42. c    
  43. c-----------------------------------------------------------------------------
  44. c
  45. c   PLEASE NOTE:
  46. c    Please note that the array pointers must all point to the first 
  47. c    element of the array "(ifx0,ify0)", "(igx0,igy0)" and "(ihx0,ihy0)"
  48. c     If "f" for example is defined as
  49. c        dimension f(-25:45,10:21)
  50. c    Then "diir2d" must be called with the following parameters
  51. c        call diir2d( f(-25,10),(45-(-25)+1),-25,45,10,21 ... )
  52. c
  53. c-----------------------------------------------------------------------------
  54. c
  55. c   This Fortran Subroutine written by
  56. c    Jean-Pierre Panziera
  57. c    Silicon Graphics Inc
  58. c    September 27, 1991
  59. c
  60. c-----------------------------------------------------------------------------
  61.  
  62.       double precision zero, one
  63.       parameter (zero = 0.0, one = 1.0)
  64.       integer iy0, iy1, ify1, igy1, ihy1
  65.       integer k1, k2, k, j, jf, jg, jh
  66.       integer ix0, ix1, ifx1, igx1, ihx1, if0, ifx, ihx
  67.  
  68. c-----------------------------------------------------------------------------
  69.     if( (n_hx .le. 0) .or. (n_hy .le. 0) ) return
  70. c-----------------------------------------------------------------------------
  71. c
  72. c   Compute Y Boundaries
  73. c
  74. c-----------------------------------------------------------------------------
  75.     ify1 = ify0 + n_fy - 1
  76.     igy1 = igy0 + n_gy - 1
  77.     ihy1 = ihy0 + n_hy - 1
  78.  
  79.     iy0 = min(max(ihy0, ify0-igy0), ihy1+1)
  80.     iy1 = max(min(ihy1, ify1-igy0), ihy0-1)
  81.  
  82.     ifx1 = ifx0 + n_fx - 1
  83.     igx1 = igx0 + n_gx - 1
  84.     ihx1 = ihx0 + n_hx - 1
  85.  
  86.     ix0 = min( max(ihx0, ifx0-igx0), ihx1+1)
  87.     ix1 = min(ihx1, ifx1-igx0)
  88.  
  89. c-----------------------------------------------------------------------------
  90. c
  91. c   Zero the Front columns
  92. c
  93. c-----------------------------------------------------------------------------
  94.     do j = ihy0, iy0-1
  95.         ihx = 1
  96.         jh = 1 + (j-ihy0)
  97.         do k = 1, n_hx
  98.         h(ihx,jh) = zero
  99.         ihx = ihx + inch
  100.         end do
  101.     end do
  102. c-----------------------------------------------------------------------------
  103. c
  104. c   Init the Plain columns
  105. c
  106. c-----------------------------------------------------------------------------
  107.     if0 = 1 + ((ix0+igx0)-ifx0) * incf
  108.     do j = iy0, iy1
  109.         ihx = 1
  110.         jh = 1 + (j-ihy0)
  111.         do k = ihx0, ix0-1
  112.         h(ihx,jh) = zero
  113.         ihx = ihx + inch
  114.         end do
  115.         ifx = if0
  116.         jf = 1 + (j+igy0-ify0)
  117.         do k = k, ix1
  118.         h(ihx,jh) = f(ifx,jf)
  119.         ihx = ihx + inch
  120.         ifx = ifx + incf
  121.         end do
  122.         do k = k, ihx1
  123.         h(ihx,jh) = zero
  124.         ihx = ihx + inch
  125.         end do
  126.     end do
  127. c-----------------------------------------------------------------------------
  128. c
  129. c   Zero the TAIL columns
  130. c
  131. c-----------------------------------------------------------------------------
  132.     do j = iy1+1, ihy1
  133.         ihx = 1
  134.         jh = 1 + (j-ihy0)
  135.         do k = 1, n_hx
  136.         h(ihx,jh) = zero
  137.         ihx = ihx + inch
  138.         end do
  139.     end do
  140. c-----------------------------------------------------------------------------
  141.     if( (n_gx .le. 0) .or. (n_gy .le. 0) ) return
  142. c-----------------------------------------------------------------------------
  143. c
  144. c   Call the 1D Convolution
  145. c
  146. c-----------------------------------------------------------------------------
  147.     do j = iy0, ihy1
  148.         jh = j-ihy0 + 1
  149.         k1 = max( iy0, j-(n_gy-1))
  150.         k2 = j-1
  151.         do k = k1, k2
  152.         jf = k-ihy0 + 1
  153.         jg = j-k + 1
  154.         call dfir1d(    h(1,jf), inch, ihx0, n_hx,
  155.      $                g(1,jg), incg,    0, n_gx,
  156.      $                h(1,jh), inch, ihx0, n_hx,
  157.      $                -one, one)
  158.         end do
  159.         call diir1d(    h(1,jh), inch, ihx0, n_hx,
  160.      $                g(1,1 ), incg,    0, n_gx,
  161.      $                h(1,jh), inch, ihx0, n_hx)
  162.     end do
  163. c-----------------------------------------------------------------------------
  164.       return
  165.       end
  166.  
  167.  
  168.